#include <REGX52.H>


void Delay1ms(unsigned int time)		//@11.0592MHz
{
	unsigned char i, j;
	while(time--)
	{
		i = 2;
		j = 199;
		do
		{
			while (--j);
		} while (--i);
	}
}
int main()
{
	unsigned char c=0;
	P2=0xfe;// 1111 1110, the first light
	while(1)
	{
		if(P3_1==0)//P3_1,the left board
		{
			Delay1ms(20);
			while(P3_1==0);
			Delay1ms(20);
			c=(c-1)%8;
		}
		else if(P3_0==0)//P3_0, the right board
		{
			Delay1ms(20);
			while(P3_0==0);
			Delay1ms(20);
			c=(c+1)%8;//c is the left move step number
		}
		P2=~(0x01<<c);

	}
	return 0;
}
